package com.atzxh.collection;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 小红同学
 * @create 2022-10-11-9:53
 * @description
 */
public class Collection_Method {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        List list = new ArrayList();

        //1. add
        list.add("kack");
        list.add(10); // list.add(new Integer(10))
        list.add(true);

        System.out.println("list:" + list);
        System.out.println("==================");
        //2. remove
        //list.remove(new Integer(10));
        //list.remove(0);
        //list.remove(true);

        System.out.println("list:" + list);
        System.out.println("==================");

        //3. contains:查找元素是否存在
        boolean contains = list.contains(true);
        System.out.println(contains);
        System.out.println("==================");

        //4. size
        int size = list.size();
        System.out.println(size);
        System.out.println("==================");

        //5. isEmpty
        boolean empty = list.isEmpty();
        System.out.println(empty);
        System.out.println("==================");

        //6. clear:清空
        //list.clear();
//        boolean empty1 = list.isEmpty();
//        int size1 = list.size();
//        System.out.println(empty1);
//        System.out.println(size1);
//        System.out.println("==================");

        //7. addAll 添加多个元素
        ArrayList list2 = new ArrayList();
        list2.add("张三");
        list2.add("李四");
        list.addAll(list2);
        System.out.println("list: "+list);
        System.out.println("list2: "+list2);
        //查找多个元素是否存在
        System.out.println(list.containsAll(list2));
        //删除多个元素
        list.removeAll(list2);

        System.out.println(list);

    }
}
